//
//  MainPlayView.m
//  AVplayer_self
//
//  Created by vicnic on 16/10/20.
//  Copyright © 2016年 vicnic. All rights reserved.
//

#import "MainPlayView.h"
#import "PlayView.h"
#import "Masonry.h"
#import "ZFDownloadManager.h"
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height

#define PlayerWidth  MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)
#define PlayerHeight (PlayerWidth * (9.0 / 16.0))
@interface MainPlayView ()
{
    PlayView * _view;
}
@end

@implementation MainPlayView

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationController.navigationBarHidden = YES;
    NSString * filePath = @"http://baobab.wdjcdn.com/14587897797934.mp4";
    
    UIButton * btn1 = [[UIButton alloc]initWithFrame:CGRectMake(50, 300, 100, 100)];
    btn1.backgroundColor = [UIColor yellowColor];
    [btn1 addTarget:self action:@selector(btnClick1) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview: btn1];
    UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(250, 300, 100, 100)];
    btn.backgroundColor = [UIColor redColor];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview: btn];
    
    _view = [[PlayView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 9*ScreenWidth/16) WithVideoStr:filePath];
    _view.titleName = @"我是标题";
    [self.view addSubview:_view];
    [_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.right.offset(0);
        make.top.offset(0);
        make.height.offset(PlayerHeight);
    }];
    
    __weak typeof(self) weakSelf = self;
    _view.goBackBlock = ^{
        [weakSelf.navigationController popViewControllerAnimated:YES];
    };
}
-(void)btnClick
{
    [[ZFDownloadManager sharedInstance]deleteFile:@"http://baobab.wdjcdn.com/1458625865688ONE.mp4"];
}
-(void)btnClick1
{
    NSLog(@">>>>>>>>%@",ZFFileFullpath(@"http://baobab.wdjcdn.com/1458625865688ONE.mp4"));
    [[ZFDownloadManager sharedInstance]download:@"http://baobab.wdjcdn.com/1458625865688ONE.mp4" progress:^(CGFloat progress, NSString *speed, NSString *remainingTime, NSString *writtenSize, NSString *totalSize) {
    } state:^(DownloadState state) {
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
